/**
 * Project Name:springBoot-serviceImpl
 * File Name:FreamXmlServiceImpl.java
 * Package Name:com.libra.serviceImp
 * Date:2018年10月31日上午11:41:03
 * Copyright (c) 2018, wangzhch All Rights Reserved.
 *
*/

package com.libra.serviceImp;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.libra.model.vo.ResponseData;
import com.libra.model.xml.TestManyNodeXml;
import com.libra.model.xml.TestOneNodeXml;
import com.libra.model.xml.TestRoundNodeXml;
import com.libra.service.FreamXmlService;
import com.libra.service.utils.FreamXmlComponent;
import com.libra.service.utils.PathUtil;
import com.libra.service.utils.XmlUtils;

/**
 * ClassName:FreamXmlServiceImpl <br/>
 * Date:     2018年10月31日 上午11:41:03 <br/>
 * @author   wangzhch
 * @version  
 * @since    JDK 1.8
 * @see 	 
 */
@Service
public class FreamXmlServiceImpl implements FreamXmlService {

	private Logger log = LoggerFactory.getLogger(FreamXmlServiceImpl.class);
	/**
	 * 
	 * 1.使用模板组装单个节点的xml报文<单节点>
	 * @see com.libra.service.FreamXmlService#testXml(com.libra.model.xml.TestOneNodeXml)
	 */
	@Override
	public ResponseData testOneNodeXml(TestOneNodeXml testXml) {
		log.info("1.使用模板组装xml报文<单节点>:{}",JSON.toJSONString(testXml));
		Map<String,Object> map = FreamXmlComponent.testOneNodeXml(testXml);
		String path = PathUtil.getWebRootPath()+"xml";
		String requestXMl = XmlUtils.createXmlFile(path, "1001.单个节点报文模板.xml", "gbk", map);
		return null;
	}
	/**
	 * 
	 * 2.使用模板组装2个以上节点的xml报文<多节点>
	 * @see com.libra.service.FreamXmlService#testManyNodeXml(com.libra.model.xml.TestManyNodeXml)
	 */
	@Override
	public ResponseData testManyNodeXml(TestManyNodeXml testManyNodeXml) {
		log.info("2.使用模板组装2个以上节点的xml报文<多节点>:{}",JSON.toJSONString(testManyNodeXml));
		Map<String,Object> map = FreamXmlComponent.testManyNodeXml(testManyNodeXml);
		String path = PathUtil.getWebRootPath()+"xml";
		String requestXMl = XmlUtils.createXmlFile(path, "1002.多个节点报文模板.xml", "gbk", map);
		return null;
	}
	/**
	 * 
	 * 3.list节点循环
	 * @see com.libra.service.FreamXmlService#testRoundNodeXml(com.libra.model.xml.TestRoundNodeXml)
	 */
	@Override
	public ResponseData testRoundNodeXml(TestRoundNodeXml testRoundNodeXml) {
		log.info("3.list节点循环:{}",JSON.toJSONString(testRoundNodeXml));
		Map<String,Object> map = FreamXmlComponent.testRoundNodeXml(testRoundNodeXml);
		String path = PathUtil.getWebRootPath()+"xml";
		String requestXMl = XmlUtils.createXmlFile(path, "1003.list节点循环报文模板.xml", "gbk", map);
//		String requestXMl = XmlUtils.createXmlFile("D:\\xmlMB", "1003.list节点循环报文模板.xml", "gbk", map);
		return null;
	}

}

